<?php
/**
 * @author andery <andery@foxmail.com>
 * @link http://www.minophp.com/
 * @version $Id: CException.php 2009-09-03 17:32:40Z andery $
 */
class CException extends Exception
{
	
	//public $maxSourceLines = 25;
	//private $type = null;
	
    /**
     * 构造函数
     *
     * @param string $message 错误消息
     * @param int $code 错误代码
     */
    /*
    public function __construct($message, $code)
    {
        parent::__construct($message, $code);
    }
    
    public function getError(){
    	$this->type = get_class($this);
    	$trace = $this->getTrace();
        $this->class = $trace[0]['class'];
        $this->function = $trace[0]['function'];
        $this->file = $trace[0]['file'];
        $this->line = $trace[0]['line'];
        $traceInfo='';
        $time = date("y-m-d H:i:m");
        foreach($trace as $t) {
            $traceInfo .= '['.$time.'] '.$t['file'].' ('.$t['line'].') ';
            $traceInfo .= !empty($t['class'])?$t['class']:'';
            $traceInfo .= !empty($t['type'])?$t['type']:'';
            $traceInfo .= !empty($t['function'])?$t['function']:'';
            $traceInfo .= '(';
            if(!empty($t['args'])){
            	foreach($t['args'] as $ta){
	                if(is_array($ta)){
	                	$traceInfo .= 'array, ';
	                }else{
	                	$traceInfo .= $ta.', ';
	                }
	            }
	            $traceInfo = substr($traceInfo, 0, -2);	
            }	
            $traceInfo .=")\n";
        }
        $error['message']   = $this->message;
        $error['type']      = $this->type;
        $error['class']     = $this->class;
        $error['function']  = $this->function;
        $error['file']      = $this->file;
        $error['line']      = $this->line;
        $error['source']    = $this->getSourceLines($this->file,$this->line);
        $error['trace']     = $traceInfo;
        return $error;
    }
    
    protected function getSourceLines($file,$line)
	{
		$maxLines=$this->maxSourceLines;
		if($maxLines<1)
			$maxLines=1;
		else if($maxLines>100)
			$maxLines=100;

		$line--;
		if($line<0 || ($lines=@file($file))===false || ($lineCount=count($lines))<=$line)
			return array();

		$halfLines=(int)($maxLines/2);
		$beginLine=$line-$halfLines>0?$line-$halfLines:0;
		$endLine=$line+$halfLines<$lineCount?$line+$halfLines:$lineCount-1;

		$sourceLines=array();
		for($i=$beginLine;$i<=$endLine;++$i)
			$sourceLines[$i+1]=$lines[$i];
		return $sourceLines;
	}*/
}